package cn.com.kingyea.es.test;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;

import java.net.InetAddress;

/**
 * Created by hshe on 2017/9/5.
 */
public class EsLoader {
    public void init() throws Exception {
        Settings esSettings = Settings.builder()

                .put("cluster.name", "kingyea") //设置ES实例的名称

                .put("client.transport.sniff", true) //自动嗅探整个集群的状态，把集群中其他ES节点的ip添加到本地的客户端列表中

                .build();
        PreBuiltTransportClient client = new PreBuiltTransportClient(esSettings);
        client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("ip"), 222));

    }
}
